// eslint-disable-next-line no-extra-semi
;(() => {
  const doc = document.documentElement
  let dpr = window.devicePixelRatio || 1
  doc.setAttribute('data-dpi', dpr)
  if (dpr > 2) {
    dpr = 2
  } else if (dpr >= 3) {
    dpr = 3
  } else {
    dpr = 1
  }

  function fit() {
    let w = doc.getBoundingClientRect().width
    /* 限制最大尺寸 */
    if (w / dpr > 550) {
      w = 550 * dpr
    }
    // 当前设备的屏幕宽度  / 设计稿的宽度
    doc.style.cssText = `font-size:${(w * 37.5) / 750}px;`
  }
  fit()
  /** 兼容移动端 */
  const eventName = window.onorientationchange ? 'orientationchange' : 'resize'
  window.addEventListener(eventName, fit)
})()
